﻿<template>
    <div id="app">
        <mt-header v-bind:title="title" style="background-color:#fda10e">
            <a slot="left" @click="back">返回</a>

        </mt-header>

        <div class="mui-content" style="background-color:#f5f5f5;">

            <form class="mui-input-group">
                <div class="mui-table-view-cell">
                    <a  class="mui-navigate-right">
                        是否同意
                        <span class="mui-pull-right" @click="choosetype">
                            {{type}}
                        </span>
                    </a>
                </div>


                <p style="margin:10px;">回复</p>

                <div class="mui-input-view" style="margin: 10px 5px;">
                    <textarea id="textarea" rows="5" v-model="desc" placeholder=""></textarea>
                </div>


                <p style="text-align:center;padding-bottom:10px;">
                    <Button type="error" shape="circle" style="width:80%;background-color:#fea00a" @click="sub">提交</Button>
                </p>

            </form>
        </div>
        <mt-popup class="sharePopup" v-model="popupVisible" position="bottom" style="width:100%;">
            <Row style="margin-top:10px;">
                <Col span="12">
                <a style="text-align:center;width:100%;display:block;font-size:18px" @click="close">取消</a>
                </Col>
                <Col span="12">
                <a style="text-align:center;width:100%;display:block;font-size:18px" @click="savetype">确定</a>
                </Col>
            </Row>


            <mt-picker :slots="slots" @change="typechange"></mt-picker>

        </mt-popup>
    </div>

    

</template>

<script>
    import { Toast } from 'mint-ui';
    import { DatetimePicker } from 'mint-ui';
    import Bus from '../bus.js'
    export default {
        name: 'app',
        data() {
            return {
                title: '请假审核',
                state: false,
                desc: "",
                type: "请选择",
                choosetypevalue:"",
                popupVisible: false,
                slots: [{ values: ['同意', '不同意'] }]

            }
        },
        components: {

        },
        mounted() {
            window.history.pushState('forward', null, '#');
            window.history.forward(1);
            window.onpopstate = () => {
                this.$router.go(-1);
            }
        },
        methods:
        {
            savetype: function () {
                this.$data.type = this.$data.choosetypevalue;
                this.$data.popupVisible = false;
            },
            close: function () {
                this.$data.popupVisible = false;
            },
            choosetype: function () {
                this.$data.popupVisible = true;


            },
            typechange: function (picker, values) {
                this.$data.choosetypevalue = values[0];

            },
            openPicker() {
                this.$refs.picker.open();
            },
            sub: function () {
                
                var userid = window.localStorage.getItem('userid');
                var id = this.$route.params.id;
                var type = this.$data.type;
                var desc = this.$data.desc;

                if (type == "请选择") {
                    Toast("请选择");
                } else {
                    var state = "";
                    if (type == "同意") {
                        state = 1;
                    } else if (type == "不同意") {
                        state = -1;
                    }
                    this.$api.post('wx/Index/leavesh', {
                        "id": id,
                        "userid": userid,
                        "state": state,
                        "desc": desc,
                    }, response => {
                        console.log(response.status);
                        if (response.status >= 200 && response.status < 300) {
                            var data = response.data;
                            if (data.status == 200) {
                                Toast(data.message);
                                this.$router.push("home");
                            } else {
                                Toast(data.message);
                            }
                            //this.$data.code = response.data;

                            //请求成功，response为成功信息参数
                        } else {

                            console.log(response.message);
                            //请求失败，response为失败信息
                        }
                    });
                }
              

               

            },
          
            load: function () {
              
            },
            back: function () {
             
                this.$router.back();
            }
        },
        created: function () {
            this.load();
        }

    }
</script>

<style scoped>
</style>